home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / gcc / gcc261c.zoo / objects / Connection.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-18  |  7.0 KB  |  201 lines

  1. /* Interface for GNU Objective-C connection for remote object messaging
  2.    Copyright (C) 1994 Free Software Foundation, Inc.
  3.    
  4.    Written by:  R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
  5.    Date: July 1994
  6.    
  7.    This file is part of the GNU Objective C Class Library.
  8.  
  9.    This library is free software; you can redistribute it and/or
  10.    modify it under the terms of the GNU Library General Public
  11.    License as published by the Free Software Foundation; either
  12.    version 2 of the License, or (at your option) any later version.
  13.    
  14.    This library is distributed in the hope that it will be useful,
  15.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.    Library General Public License for more details.
  18.    
  19.    You should have received a copy of the GNU Library General Public
  20.    License along with this library; if not, write to the Free
  21.    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.    */ 
  23.  
  24. #ifndef __Connection_h_OBJECTS_INCLUDE
  25. #define __Connection_h_OBJECTS_INCLUDE
  26.  
  27. #include <objects/stdobjects.h>
  28. #include <stdlib.h>
  29. #include <stdarg.h>
  30. #include <objc/hash.h>
  31. #include <objc/Protocol.h>
  32. #include <objects/Lock.h>
  33. #include <objects/InvalidationListening.h>
  34. #include <objects/RetainingNotifier.h>
  35. #include <objects/Collecting.h>
  36. #include <objects/Dictionary.h>
  37.  
  38. @class Proxy;
  39. @class Port;
  40. @class ConnectedCoder;
  41.  
  42. @interface Connection : RetainingNotifier <InvalidationListening>
  43. {
  44.   id delegate;
  45.   Port *in_port;
  46.   Port *out_port;
  47.   unsigned message_count;
  48.   Dictionary *local_targets;
  49.   Dictionary *remote_proxies;
  50.   int in_timeout;
  51.   int out_timeout;
  52.   id port_class;
  53.   int queue_dialog_interruptions;
  54.   Dictionary *incoming_const_ptrs;
  55.   Dictionary *outgoing_const_ptrs;
  56. }
  57.  
  58. + setDefaultPortClass: aPortClass;
  59. + defaultProxyClass;
  60. + setDefaultProxyClass: aClass;
  61. + (int) defaultOutTimeout;
  62. + setDefaultOutTimeout: (int)to;
  63. + (int) defaultInTimeout;
  64. + setDefaultInTimeout: (int)to;
  65. /* Setting and getting class configuration */
  66.  
  67. + (int) messagesReceived;
  68. + (id <Collecting>) allConnections;
  69. + (unsigned) connectionsCount;
  70. + (unsigned) connectionsCountWithInPort: (Port*)aPort;
  71. /* Querying the state of all the connections */
  72.  
  73. + removeObject: anObj;
  74. + unregisterForInvalidationNotification: anObj;
  75. /* Use these when you're free'ing an object that may have been vended
  76.    or registered for invalidation notification */
  77.  
  78. + (Connection*) newWithRootObject: anObj;
  79. + (Connection*) newRegisteringAtName: (const char*)n withRootObject: anObj;
  80. /* Registering your server object on the network.
  81.    These methods create a new connection object that must be "run" in order
  82.    to start handling requests from clients. 
  83.    These method names may change when we get the capability to register
  84.    ports with names after the ports have been created. */
  85. /* I want the second method name to clearly indicate that we're not
  86.    connecting to a pre-existing registration name, we're registering a
  87.    new name, and this method will fail if that name has already been
  88.    registered.  This is why I don't like "newWithRegisteredName:" ---
  89.    it's unclear if we're connecting to another Connection that already
  90.    registered with that name. */
  91.  
  92. + (Proxy*) rootProxyAtName: (const char*)name onHost: (const char*)host;
  93. + (Proxy*) rootProxyAtName: (const char*)name;
  94. + (Proxy*) rootProxyAtPort: (Port*)anOutPort;
  95. + (Proxy*) rootProxyAtPort: (Port*)anOutPort withInPort: (Port*)anInPort;
  96. /* Get a proxy to a remote server object.
  97.    A new connection is created if necessary. */
  98.  
  99. + (Connection*) newForInPort: (Port*)anInPort outPort: (Port*)anOutPort
  100.    ancestorConnection: (Connection*)ancestor;
  101. /* This is the designated initializer for the Connection class.
  102.    You don't need to call it yourself. */
  103.  
  104. - (void) runConnectionWithTimeout: (int)timeout;
  105. /* Make a connection object start listening for incoming requests.  After 
  106.    `timeout' milliseconds without receiving anything, return. */
  107.  
  108. - (void) runConnection;
  109. /* Same as above, but never time out. */
  110.  
  111. - (id <Collecting>) proxies;
  112. /* When you get an invalidation notification from a connection, use
  113.    this method in order to find out if any of the proxy objects you're
  114.    using are going away. */
  115.  
  116. - (Proxy*) rootProxy;
  117. /* If you somehow have a connection to a server, but don't have it's
  118.    a proxy to its root object yet, you can use this to get it. */
  119.  
  120. - rootObject;
  121. + rootObjectForInPort: (Port*)aPort;
  122. /* For getting the root object of a connection or port */
  123.  
  124. + setRootObject: anObj forInPort: (Port*)aPort;
  125. - setRootObject: anObj;
  126. /* Used for setting the root object of a connection that we
  127.    created without one, or changing the root object of a connection
  128.    that already has one. */
  129.  
  130. - (int) outTimeout;
  131. - (int) inTimeout;
  132. - setOutTimeout: (int)to;
  133. - setInTimeout: (int)to;
  134. - portClass;
  135. - setPortClass: aPortClass;
  136. - proxyClass;
  137. - coderClass;
  138. - (Port*) outPort;
  139. - (Port*) inPort;
  140. - delegate;
  141. - setDelegate: anObj;
  142. /* Querying and setting some instance variables */
  143.  
  144. - (Proxy*) proxyForTarget: (unsigned)target;
  145. - addProxy: (Proxy*)aProxy;
  146. - (BOOL) includesProxyForTarget: (unsigned)target;
  147. - removeProxy: (Proxy*)aProxy;
  148. - (id <Collecting>) localObjects;
  149. - addLocalObject: anObj;
  150. - (BOOL) includesLocalObject: anObj;
  151. - removeLocalObject: anObj;
  152. - (retval_t) connectionForward: (Proxy*)object : (SEL)sel : (arglist_t)frame;
  153. - (const char *) _typeForSelector: (SEL)sel remoteTarget: (unsigned)target;
  154. - (Dictionary*) _incomingConstPtrs;
  155. - (Dictionary*) _outgoingConstPtrs;
  156. /* Only subclassers and power-users need worry about these */
  157.  
  158. @end
  159.  
  160. @protocol ConnectedCoding
  161. + (void) encodeObject: anObj withConnectedCoder: aRmc;
  162. @end
  163.  
  164. @interface Object (ConnectionDelegate)
  165. - (Connection*) connection: ancestorConn didConnect: newConn;
  166. /* If the delegate responds to this method, it will be used to ask the
  167.    delegate's permission to establish a new connection from the old one.
  168.    Often this is used so that the delegate can register for invalidation 
  169.    notification on new child connections.
  170.    Normally return newConn. */
  171. @end
  172.  
  173. #if 0 /* Put in Coder.m until ObjC runtime category-loading bug is fixed */
  174.  
  175. @interface Object (ConnectionRequests)
  176. - classForConnectedCoder: aRmc;
  177. /* Must return the class that will be created on the remote side
  178.    of the connection.
  179.    Used by the remote objects system to determine how the receiver
  180.    should be encoded across the network.
  181.    In general, you can:
  182.      return [Proxy class] to send a proxy of the receiver;
  183.      return [self class] to send the receiver bycopy. 
  184.    The Object class implementation returns [Proxy class]. */
  185. + (void) encodeObject: anObject withConnectedCoder: aRmc;
  186. /* This message is sent to the class returned by -classForConnectedCoder:
  187.    The Proxy class implementation encodes a proxy for anObject.
  188.    The Object class implementation encodes the receiver itself. */
  189. @end
  190.  
  191. @interface Object (Retaining) <Retaining>
  192. /* Make sure objects don't crash when you send them <Retaining> messages.
  193.    These implementations, however, do nothing. */
  194. @end
  195.  
  196. #endif /* 0 Put in Coder.m */
  197.  
  198. #define CONNECTION_DEFAULT_TIMEOUT   15000 /* in milliseconds */
  199.  
  200. #endif /* __Connection_h_OBJECTS_INCLUDE */
  201.